package unit03;

public class Demo04 {
    public static void main(String[] args) {
        for (int i = 1; i <= 1000; i++) {
            if (isPerfectNumber(i)) {
                System.out.println("完数: " + i);
            }
        }
    }

    private static boolean isPerfectNumber(int number) {
        int sum = 0;
        for (int j = 1; j < number; j++) {
            if (number % j == 0) {
                sum += j;
            }
        }
        return sum == number;
    }
}
